package net;

public class NameMapper implements org.apache.commons.betwixt.strategy.NameMapper
{
	public String mapTypeToElementName(String typeName) {
		String elementName = typeName;
		for (Class<?> type : types.keySet())
			try {
				if (type.isAssignableFrom(Class.forName(type.getPackage().getName() + "." + typeName))) {
					elementName = types.get(type);
					break;
				}
			} catch (ClassNotFoundException e) {
			} catch (NoClassDefFoundError e) {}
		return elementName;
	}

	public void registerType(Class<?> type, String elementName) {
		types.put(type, elementName);
	}

	private java.util.Map<Class<?>, String> types = new java.util.HashMap<Class<?>, String>();
}